package com.lumingfeng.controller;

import com.lumingfeng.entity.Goods;
import com.lumingfeng.service.GoodsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * Created by yc on 16/9/2.
 */

@RequestMapping("/goods")
@Controller
public class GoodsController {

    @Resource(name = "goodsService")
    private GoodsService goodsService;

    @RequestMapping("/add")
    public ModelAndView add(){

        ModelAndView view =new ModelAndView("in_add");
        return view;
    }

    @RequestMapping("/save")
    public  ModelAndView save(Goods goods){
        System.out.print("goods:"+goods.toString());
        Integer result = goodsService.insertGoods(goods);

        System.out.print("goods:"+result);

        ModelAndView view =new ModelAndView("in_list");
        view.addObject("inlist",goodsService.getGoods());
        return view;
    }

    @RequestMapping("/list")
    public ModelAndView list(){
        ModelAndView view =new ModelAndView("in_list");
        view.addObject("inlist",goodsService.getGoods());
        return view;
    }

    @RequestMapping("/rtlist")
    public ModelAndView rtlist(){
        ModelAndView view =new ModelAndView("in_list");
        view.addObject("inlist",goodsService.getRTGoods());
        return view;
    }
}
